]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Add pointer barriers to panel and message tray
authorAlexander Larsson <alexl@redhat.com>
Fri, 18 Mar 2011 12:27:06 +0000 (13:27 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 21 Mar 2011 20:03:19 +0000 (21:03 +0100)
If you have XFixes 5 (and corresponding xserver support) then we
add barriers on the panel and in the message tray corner so that
its easy to reach the corners even when there are monitors to the
sides of the primary monitor.

https://bugzilla.gnome.org/show_bug.cgi?id=622655

js/ui/messageTray.js
js/ui/panel.js
src/shell-global.c
src/shell-global.h

index e34d693503ec3af36e0860a60c51d8967dc2e341..ea21d494dd09e459ea3ef0b530047cbb6eb58578 100644 (file)
@@ -1030,6 +1030,7 @@ MessageTray.prototype = {
         this._clickedSummaryItemAllocationChangedId = 0;
         this._expandedSummaryItem = null;
         this._summaryItemTitleWidth = 0;
+        this._pointerBarrier = 0;
 
         // To simplify the summary item animation code, we pretend
         // that there's an invisible SummaryItem to the left of the
@@ -1119,6 +1120,15 @@ MessageTray.prototype = {
         this._notificationBin.width = primary.width;
         this._summaryBin.x = 0;
         this._summaryBin.width = primary.width;
+
+        if (this._pointerBarrier)
+            global.destroy_pointer_barrier(this._pointerBarrier);
+        this._pointerBarrier =
+            global.create_pointer_barrier(primary.x + primary.width, primary.y + primary.height - this.actor.height,
+                                          primary.x + primary.width, primary.y + primary.height,
+                                          4 /* BarrierNegativeX */);
+
+
     },
 
     contains: function(source) {
index c064245af68e8c8f826ded8483eb98093929de0b..a75cf3db212231847e4a37ede8b23cd2ee04a293 100644 (file)
@@ -789,6 +789,8 @@ Panel.prototype = {
             this.actor.remove_style_class_name('in-overview');
         }));
 
+        this._leftPointerBarrier = 0;
+        this._rightPointerBarrier = 0;
         this._menus = new PopupMenu.PopupMenuManager(this);
 
         this._leftBox = new St.BoxLayout({ name: 'panelLeft' });
@@ -1051,6 +1053,20 @@ Panel.prototype = {
         this.actor.set_position(primary.x, primary.y);
         this.actor.set_size(primary.width, -1);
 
+        if (this._leftPointerBarrier)
+            global.destroy_pointer_barrier(this._leftPointerBarrier);
+        if (this._rightPointerBarrier)
+            global.destroy_pointer_barrier(this._rightPointerBarrier);
+
+        this._leftPointerBarrier =
+            global.create_pointer_barrier(primary.x, primary.y,
+                                          primary.x, primary.y + this.actor.height,
+                                          1 /* BarrierPositiveX */);
+        this._rightPointerBarrier =
+            global.create_pointer_barrier(primary.x + primary.width, primary.y,
+                                          primary.x + primary.width, primary.y + this.actor.height,
+                                          4 /* BarrierNegativeX */);
+
         this._leftCorner.relayout();
         this._rightCorner.relayout();
     },
index 44f4aff668ff359119f212d5840b2331ba238902..dcedf43f247748ad29692981b9bbead92449a165 100644 (file)
@@ -884,6 +884,61 @@ shell_global_display_is_grabbed (ShellGlobal *global)
   return meta_display_get_grab_op (display) != META_GRAB_OP_NONE;
 }
 
+/**
+ * shell_global_create_pointer_barrier
+ * @global: a #ShellGlobal
+ * @x1: left X coordinate
+ * @y1: top Y coordinate
+ * @x2: right X coordinate
+ * @y2: bottom Y coordinate
+ * @directions: The directions we're allowed to pass through
+ *
+ * If supported by X creates a pointer barrier.
+ *
+ * Return value: value you can pass to shell_global_destroy_pointer_barrier()
+ */
+guint32
+shell_global_create_pointer_barrier (ShellGlobal *global,
+                                     int x1, int y1, int x2, int y2,
+                                     int directions)
+{
+#if XFIXES_MAJOR >= 5
+  Display *xdpy;
+
+  xdpy = meta_plugin_get_xdisplay (global->plugin);
+
+  return (guint32)
+    XFixesCreatePointerBarrier (xdpy, DefaultRootWindow(xdpy),
+                                x1, y1,
+                                x2, y2,
+                                directions,
+                                0, NULL);
+#else
+  return 0;
+#endif
+}
+
+/**
+ * shell_global_destroy_pointer_barrier
+ * @global: a #ShellGlobal
+ * @barrier: a pointer barrier
+ *
+ * Destroys the @barrier created by shell_global_create_pointer_barrier().
+ */
+void
+shell_global_destroy_pointer_barrier (ShellGlobal *global, guint32 barrier)
+{
+#if XFIXES_MAJOR >= 5
+  Display *xdpy;
+
+  g_return_if_fail (barrier > 0);
+
+  xdpy = meta_plugin_get_xdisplay (global->plugin);
+  XFixesDestroyPointerBarrier (xdpy, (PointerBarrier)barrier);
+#endif
+}
+
+
 /**
  * shell_global_add_extension_importer:
  * @target_object_script: JavaScript code evaluating to a target object
index cda10e455a3ab885dcf92cae7891c7e130be05f8..6e16abee9a9246bec2fa5e55568f84435dd26d02 100644 (file)
@@ -103,6 +103,12 @@ MetaRectangle *shell_global_get_primary_monitor (ShellGlobal  *global);
 int            shell_global_get_primary_monitor_index (ShellGlobal  *global);
 MetaRectangle *shell_global_get_focus_monitor   (ShellGlobal  *global);
 
+guint32 shell_global_create_pointer_barrier (ShellGlobal *global,
+                                             int x1, int y1, int x2, int y2,
+                                             int directions);
+void    shell_global_destroy_pointer_barrier (ShellGlobal *global,
+                                              guint32 barrier);
+
 void shell_global_get_pointer  (ShellGlobal         *global,
                                 int                 *x,
                                 int                 *y,